//
//  EqualCell.m
//  趣·美食
//
//  Created by dllo on 15/9/24.
//  Copyright (c) 2015年 金旭. All rights reserved.
//

#import "EqualCell.h"


@interface EqualCell ()

@property (nonatomic, strong) UIImageView *foodImage;
@property (nonatomic, strong) UILabel *xLabel;
@property (nonatomic, strong) UILabel *countLabel;
@property (nonatomic, strong) UILabel *subLabel;
@property (nonatomic, assign) BOOL isnight;

@end

@implementation EqualCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.foodImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.foodImage];

        
        self.xLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.xLabel];
  
        
        self.countLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.countLabel];
    
        
        self.subLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.subLabel];

    

    }
    return self;
}



- (void)setDeModel:(GFDetialsModel *)deModel {
    if (_deModel != deModel) {
        _deModel = deModel;
    }
    if (self.deModel.compare) {
        [self.foodImage setImageWithURL:[NSURL URLWithString:[self.deModel.compare objectForKey:@"target_image_url"]] placeholderImage:[UIImage imageNamed:@"category_1"]];
    }


    
    self.xLabel.text = @"X";
    
    self.countLabel.text = [self.deModel.compare objectForKey:@"amount1"];
    
    self.subLabel.text = [NSString stringWithFormat:@"%@%@%@ ≈ %@%@%@", [self.deModel.compare objectForKey:@"amount0"], [self.deModel.compare objectForKey:@"unit0"], self.deModel.name, [self.deModel.compare objectForKey:@"amount1"], [self.deModel.compare objectForKey:@"unit1"], [self.deModel.compare objectForKey:@"target_name"]];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.foodImage.frame = CGRectMake(ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 60, ScreenWidth / 375.0 * 60);
    
    self.xLabel.frame = CGRectMake(ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 25, ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 20);
    self.xLabel.textColor = [UIColor lightGrayColor];
    
    self.countLabel.frame = CGRectMake(ScreenWidth / 375.0 * 120, ScreenWidth / 375.0 * 20, ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 30);
    self.countLabel.font = [UIFont systemFontOfSize:20];
    self.countLabel.textColor = [UIColor redColor];
    
    self.subLabel.frame = CGRectMake(ScreenWidth / 375.0 * 100, ScreenWidth / 375.0 * 50, ScreenWidth - ScreenWidth / 375.0 * 120, ScreenWidth / 375.0 * 40);
    self.subLabel.font = [UIFont systemFontOfSize:15];
    self.subLabel.textColor = [UIColor lightGrayColor];
    self.subLabel.numberOfLines = 0;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
